// RecordsetPtrWrap.h: interface for the RecordsetPtrWrap class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_RECORDSETPTRWRAP_H__22188598_42E0_46A7_A5FD_EB820A256B80__INCLUDED_)
#define AFX_RECORDSETPTRWRAP_H__22188598_42E0_46A7_A5FD_EB820A256B80__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GlobalShare.h"
#include "AssocCommon.h"

namespace DAWrapper
{
class AFX_EXT_CLASS RecordsetPtrWrap  
{
public:
	RecordsetPtrWrap();
	~RecordsetPtrWrap();

public:
	HRESULT Set( const CString& queryStatement, const _ConnectionPtr& connPtr );
	CString GetString( const char* field ) { return vtos( GetCollect( field ) ); }
	float GetFloat( const char* field ) { return (float)GetCollect( field ); }
	DOUBLE GetDouble( const char* field ) { return (double)GetCollect( field ); }
	short GetShort( const char* field ) { return (short)GetCollect( field ); }
	long GetLong( const char* field ) { return (long)GetCollect( field ); }
	INT GetInt( const char* field ) { return (long)GetCollect( field ); }
	bool GetBool( const char* field ) { return (bool)GetCollect( field ); }
	_variant_t GetCollect( const char* field ) { try { return m_RS->GetCollect( field ); }
	catch ( _com_error e ) { ErrorAlert( e ); return _variant_t(); } }
	LONG GetRecordCount() const { return m_RS->GetRecordCount(); }
	BOOL IsBOF() const { return m_RS->BOF; }
	BOOL IsEOF() const { return m_RS->adoEOF; }
	VOID MoveNext() { m_RS->MoveNext(); }
	VOID MoveFirst() { m_RS->MoveFirst(); }
	_ConnectionPtr GetSource() { return m_RS->GetActiveConnection(); }

private:
	void Close() { if ( m_RS != 0 && m_RS->GetState() == adStateOpen ) m_RS->Close(); }

private:
	_RecordsetPtr m_RS;
};
}

#endif // !defined(AFX_RECORDSETPTRWRAP_H__22188598_42E0_46A7_A5FD_EB820A256B80__INCLUDED_)
